package com.unlcn.erp.hyc.interfaces.api.controller;

import cn.huiyunche.commons.domain.ResultDTO;
import cn.huiyunche.commons.exception.BusinessException;
import com.unlcn.erp.hyc.interfaces.backend.service.CallReceivableCodesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by zoupx on 2017-09-07.
 */

@Controller
@RequestMapping("/callReceivableOrder")
public class CallReceivableOrderController {
    private static final Logger LOGGER = LoggerFactory.getLogger(CallReceivableOrderController.class);

    @Autowired
    private CallReceivableCodesService callReceivableCodesService;

    @RequestMapping(value = "/saveReceivableOrder" ,method = RequestMethod.GET)
    @ResponseBody
    public void saveOrderByHYC(){
        LOGGER.info("CallReceivableOrderController.saveReceivableOrder param:{}.");
        ResultDTO<Object> result = new ResultDTO<Object>(true, null, "查询成功");
        try{
             callReceivableCodesService.getCodes();
        }catch (Exception e){
            LOGGER.error("TmsPickUpController.getExcepList error: {}", e);
            throw new BusinessException(e);
        }
    }

    @RequestMapping(value = "/updateArorder" ,method = RequestMethod.GET)
    @ResponseBody
    public void updateArorder(){
        LOGGER.info("CallReceivableOrderController.updateArorder param:{}.");
        ResultDTO<Object> result = new ResultDTO<Object>(true, null, "查询成功");
        try{
            callReceivableCodesService.updateArorder();
        }catch (Exception e){
            LOGGER.error("TmsPickUpController.getExcepList error: {}", e);
            throw new BusinessException(e);
        }
    }

    @RequestMapping(value = "/saveArorder" ,method = RequestMethod.GET)
    @ResponseBody
    public void saveArorder(String billCode){
        LOGGER.info("CallReceivableOrderController.updateArorder param:{}.");
        ResultDTO<Object> result = new ResultDTO<Object>(true, null, "查询成功");
        try{
//            callReceivableCodesService.saveArorderByBillCode(billCode);
        }catch (Exception e){
            LOGGER.error("TmsPickUpController.getExcepList error: {}", e);
            throw new BusinessException(e);
        }
    }

    @RequestMapping(value = "/cashReceipts" , method = RequestMethod.GET)
    @ResponseBody
    public void cashReceipts(){
        LOGGER.info("CallReceivableOrderController.updateArorder param:{}.");
        ResultDTO<Object> result = new ResultDTO<Object>(true, null, "查询成功");
        try{
            callReceivableCodesService.cashReceipts();
        }catch (Exception e){
            LOGGER.error("TmsPickUpController.getExcepList error: {}", e);
            throw new BusinessException(e);
        }
    }

}
